﻿using IQReportes.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace IQReportes.Utils
{
    public static class HtmlHelpers
    {
        //{0} button class {1}num modulo {2} idTipoChart , {3} icono de chart
        static string buttonTipoChart = @"<button type='button' class='{0}'
                                    id='radioModulo{1}_{2}' onclick = 'cambiarChart({2},{1})'>
                                    <i class='{3}'></i></button>";
        //pie, column, line, table
        //static string[] iconosTipoChart = { "iconos icon-pie-chart", "iconos icon-charts", "iconos icon-stats", "iconos icon-table" };
        static string[] iconosTipoChart = { "icomoon-pie", "icomoon-bars", "icomoon-stats", "icomoon-table" };
        static string buttonTipoChartClass = "btn ";
        static string inicioButtonTipoChart = "<span class='btn-group' data-toggle='buttons-radio'>";
        static string finButtonTipoChart="</span>";
        public static MvcHtmlString BotonesTipoChart(this HtmlHelper helper, List<ComboValores> radioTiposChart,int modulo,int seleccion)
        {
            //Model.radioTiposChart,numModulo
            var sb = new StringBuilder();
            sb.Append(inicioButtonTipoChart);
            for (int i = 0 ; i<radioTiposChart.Count; i++)
            {
                var active = "";
                if (radioTiposChart[i].id == seleccion)
                {
                    active = "active";
                }
                sb.AppendFormat(buttonTipoChart, buttonTipoChartClass+active, modulo , radioTiposChart[i].id , iconosTipoChart[i] );
            }
            sb.Append(finButtonTipoChart);
            return new MvcHtmlString(sb.ToString());
        }

        static string buttonDescargaTemplate =@"<span><button type='button' class='{0}' onclick='descargar({1})'><span class='{2}'></span></button></span>";
        static string buttonDescargaClass = "btn";
        static string iconoDescarga = "icon-download-alt";
        public static MvcHtmlString BotonDescarga(this HtmlHelper helper,int modulo){
            var sb = new StringBuilder();
            sb.AppendFormat(buttonDescargaTemplate,buttonDescargaClass,modulo,iconoDescarga);
            return new MvcHtmlString(sb.ToString());
        }
    }
    
}